import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class SumpApp extends Applet{

	int a,b,c;
	TextField operand1=new TextField(5);
	TextField operand2=new TextField(5);
	TextField result=new TextField(5);

	public void init(){

		Panel p1=new Panel();
		//TextField operand1=new TextField(5);
		//TextField operand2=new TextField(5);
		//TextField result=new TextField(5);
		Button sum=new Button("ADD");
		Button sub=new Button("SUB");
			
		p1.add(operand1);
		p1.add(operand2);
		p1.add(result);
		p1.add(sum);
		p1.add(sub);
		
		operand1.setForeground(Color.blue);
		operand2.setForeground(Color.blue);
		result.setForeground(Color.blue);
		
		sum.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent evt){
				a=Integer.parseInt(operand1.getText());
				b=Integer.parseInt(operand2.getText());
				c=a+b;
				result.setText(""+c);
				showStatus("Sum displayed");
			}
		});
		
		sub.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent evt){
				a=Integer.parseInt(operand1.getText());
				b=Integer.parseInt(operand2.getText());
				c=a-b;
				result.setText(""+c);
				showStatus("Difference displayed");
			}
		});
	
		result.setEditable(false);
		add(p1);
	}
	
}
